package _09递归案例_遍历文件夹;

import java.io.File;

public class Demo {
    public static void main(String[] args) {
        File file = new File("D:\\黑马java培训班\\代码\\itcast\\JavaSE\\day09");
        getAllJava(file);
    }

    private static void getAllJava(File file) {
        File[] files = file.listFiles();
        for (File f : files) {
            if (f.isFile()){
                String name = f.getName();
                if (name.endsWith(".java"))
                    System.out.println(name);
            }else if (f.isDirectory()){
                getAllJava(f);
            }
        }
    }
}
